import os
import os.path

dir = './'


def listUiFile():
    list = []
    files = os.listdir(dir)
    for fileName in files:
        if os.path.splitext(fileName)[1] == '.ui':
            list.append(fileName)
    return list


def transPyFile(fileName):
    return os.path.splitext(fileName)[0] + '.py'


def runMain():
    list = listUiFile()
    for uiFile in list:
        pyFile = transPyFile(uiFile)
        cmd = 'pyuic5 -o {pyfile} {uifile}'.format(
            pyfile=pyFile, uifile=uiFile)
        os.system(cmd)


if __name__ == '__main__':
    runMain()
